package com.shuhua.taskServer.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shuhua.pojo.entity.TaskComment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;

@Mapper
public interface TaskCommentMapper extends BaseMapper<TaskComment> {
    @Select("SELECT tc.*, c.username as craftsman_username, c.phone as craftsman_phone, c.real_name as craftsman_real_name, c.department as craftsman_department, c.station as craftsman_station, c.avatar as craftsman_avatar FROM task_comment tc LEFT JOIN craftsman c ON tc.commentman_id = c.id WHERE tc.id = #{id} LIMIT 1")
    Map<String, Object> selectTaskCommentWithCraftsmanById(@Param("id") Long id);

    @Select("SELECT tc.*, c.username as craftsman_username, c.phone as craftsman_phone, c.real_name as craftsman_real_name, c.department as craftsman_department, c.station as craftsman_station, c.avatar as craftsman_avatar FROM task_comment tc LEFT JOIN craftsman c ON tc.commentman_id = c.id")
    List<Map<String, Object>> selectAllTaskCommentWithCraftsman();

    @Select("SELECT tc.*, c.username as craftsman_username, c.phone as craftsman_phone, c.real_name as craftsman_real_name, c.department as craftsman_department, c.station as craftsman_station, c.avatar as craftsman_avatar FROM task_comment tc LEFT JOIN craftsman c ON tc.commentman_id = c.id WHERE tc.task_id = #{taskId}")
    List<Map<String, Object>> selectTaskCommentWithCraftsmanByTaskId(@Param("taskId") Long taskId);
} 